/*
 * ColorChooser.java  0.4.0 / Oct 25, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
package com.cute4j.swing;

import com.cute4j.swing.graphics.Color;

/**
 * Color Chooser Component.
 *
 * @cute4j.native
 *    generate="header"
 *
 * @author Slobodan Vrkacevic
 * @version 0.4.0
 */
public final class ColorChooser extends Dialog {

// Private Constructor. --------------------------------------------------------

 /**
  * Class has no instances.
  */
  private ColorChooser() {
    // empty constructor body
  }

// Public Static Methods. ------------------------------------------------------

  /**
   * Returns color selected by the user.
   *
   * @param parent the parent component
   *
   * @return color selected by the user
   */
  public static Color getColor(Component parent) {
    return getColor(parent, null);
  }

  /**
   * Returns color selected by the user.
   *
   * @param parent the parent component
   * @param initialColor the initial color
   *
   * @return color selected by the user
   */
  public static Color getColor(Component parent, Color initialColor) {
    int argb;
    if (initialColor == null) {
      argb = 0xFFFFFFFF;
    } else {
      argb = initialColor.getARGB();
    }
    if (parent != null) {
      return _getColor(parent._delegate, argb);
    }
    return _getColor(0, argb);
  }

// Package-Private Static Native Methods. --------------------------------------

  static native Color _getColor(long parentDelegate, int initialColor);

}
